﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Comom.Project.ControllerCom;
using Dhtl.Service.IService;
using dai_hoc_tuong_lai.Areas.Admin.Models;

namespace dai_hoc_tuong_lai.Controllers
{
    public class TuyenSinhController : UTController
    {
        //
        // GET: /TuyenSinh/
        private readonly IThongtintuyensinh _iNews;
        private readonly int PageSize = 15;

        public TuyenSinhController(IThongtintuyensinh iNews)
        {
            this._iNews = iNews;
        }

        public ActionResult ListOnIndex()
        {
            var listEntity = _iNews.List();
            List<ThongtintuyensinhModel> model = new List<ThongtintuyensinhModel>();
            try
            {
                foreach (var item in listEntity)
                {
                    ThongtintuyensinhModel ml = new ThongtintuyensinhModel();
                    ThongtintuyensinhModel.MapFrom(item, ref  ml);
                    model.Add(ml);
                }
            }
            catch { }

            return PartialView("_ListOnIndex", model);
        }

        public ActionResult List()
        {

            var listEntity = _iNews.List();
            List<ThongtintuyensinhModel> model = new List<ThongtintuyensinhModel>();
            try
            {
                if (listEntity.Count() > 10) listEntity = listEntity.Take(10).ToList();

                foreach (var item in listEntity)
                {
                    ThongtintuyensinhModel ml = new ThongtintuyensinhModel();
                    ThongtintuyensinhModel.MapFrom(item, ref  ml);
                    model.Add(ml);
                }
            }
            catch { }


            return PartialView("_List", model);
        }

        public ActionResult NewsDetails(int id, string name)
        {
            var entity = _iNews.GetById(id);
            ThongtintuyensinhModel ml = new ThongtintuyensinhModel();
            ThongtintuyensinhModel.MapFrom(entity, ref  ml);
            return View(ml);
        }

        public ActionResult Index()
        {
            return View();
        }

    }
}
